package com.app.activitys.adapters;

import java.util.List;

import com.app.entidades.Bar;
import com.app.entidades.Show;
import com.example.applucianokikao.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AdapterShow extends ArrayAdapter{

private List<Show> shows;
	
	// used to keep selected position in ListView
		private int selectedPos = -1;	// init value for not-selected

		public AdapterShow(Context context, int textViewResourceId,
	                       List objects) {
			super(context, textViewResourceId, objects);
			shows = objects;
		}

		public void setSelectedPosition(int pos){
			selectedPos = pos;
			// inform the view of this change
			notifyDataSetChanged();
		}

		public int getSelectedPosition(){
			return selectedPos;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
		    View v = convertView;

		    if (v == null) {
		        LayoutInflater vi
	                        = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		        v = vi.inflate(R.layout.adapter_show_view,null);
		    }

		    TextView nome_show = (TextView)v.findViewById(R.id.txt_nome_show);
	        TextView local_show = (TextView)v.findViewById(R.id.txt_local_show);
	        
	       	nome_show.setBackgroundColor(R.color.cinza_2);
	       	local_show.setBackgroundColor(R.color.cinza_2);
       
	       	nome_show.setText(shows.get(position).getNome());
	       	local_show.setText(shows.get(position).getLocal());
	        
	        return(v);
		}

}
